package com.example.mapp;

import com.example.entity.Information;
import com.example.ext.entity.ExtInformation;
import com.example.mapp.buildSql.InformationMappSql;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * Created by youkun on 2017/9/22.
 */
@Mapper
public interface InformationMapp {
    @Select(" select * from information  where id=#{id}")
    Information queryById(String id) throws Exception;

    @Delete("delete from information where id=#{id}")
    int deleteById(String id) throws Exception;

    @Insert(" insert into information (title,sub_title,content,create_user_id,create_party_id,file_urls,create_time,is_init) " +
            "value (#{title},#{subTitle},#{content},#{createUserId},#{createPartyId},#{fileUrls},#{createTime},#{isInit})")
    @SelectKey(statement="select last_insert_id()",keyProperty = "id",keyColumn = "id",before = false,resultType = Long.class)
    int add(ExtInformation extInformation) throws Exception;

    @Update(" update information set title=#{title},sub_title=#{subTitle},file_urls=#{fileUrls},content=#{content} where id=#{id}")
    int update(ExtInformation extInformation)throws Exception;

    @SelectProvider(type = InformationMappSql.class,method = "queryList")
    List<ExtInformation> queryList(ExtInformation extInformation);

    @SelectProvider(type = InformationMappSql.class,method = "countList")
    int countList(ExtInformation extInformation);
}
